﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NUnit.Framework;
using Contoso.Models;
using Moq;

namespace Contoso.Tests.Helpers
{
    public static class UnitTestHelpers
    {
        public static void ShouldEqual<T>(this T actualValue, T expectedValue)
        {
            Assert.AreEqual(expectedValue, actualValue);
        }

        public static IUnitOfWork MockUnitOfWork(List<Student> students)
        {
            var mockUnitOfWork = new Mock<IUnitOfWork>();

            mockUnitOfWork.Setup(x => x.StudentsRepository.Students()).Returns(students.AsQueryable());
            mockUnitOfWork.Setup(x => x.StudentsRepository.Add(It.IsAny<Student>())).Callback<Student>(s => students.Add(s));

            return mockUnitOfWork.Object;
        }
    }
}
